package Test;

import java.lang.reflect.Array;
import java.util.*;

/**
 * @ClassName Main2
 * @Description
 * @Company inspur
 * @Author Kevin
 * @Date 2020/7/22 11:25
 * @Version 1.0
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n < 4 || n > 5000) {
            System.out.println(-1);
            return;
        }
        HashMap<Integer, Integer> map = new HashMap<>();
        //首先取数并统计
        while (n>0) {
            int num = sc.nextInt();
            if (!map.containsKey(num)) {
                map.put(num, 0);
            }
            map.put(num, map.get(num)+1);
            n--;
        }
        sc.close();
        //取出其中次数大于等于2的，可以构建边的；而且
        List<Integer> raws = new ArrayList<>();
        for (Integer key: map.keySet()) {
            if (map.get(key) >= 2) {
                raws.add(key);
            }
        }
        //判断是否可以构建平行四边形
        if (raws.size() >= 2 || (raws.size()==1 && map.get(raws.get(0)) >= 4)) {
            if (raws.size()==1) {
                System.out.println(raws.get(0) * raws.get(0));
                return;
            }
            //排序,取最大两个
            int[] temp = new int[raws.size()];
            for (int i = 0; i < raws.size(); i++) {
                temp[i] = raws.get(i);
            }
            Arrays.sort(temp);
            int r = temp[raws.size()-1 ];
            if (map.get(r) >= 4) {
                System.out.println(r*r);
                return;
            }
            int l = temp[raws.size()-2 ];
            System.out.println(l*r);
        } else {//不可以
            System.out.println(-1);
            return;
        }
    }
}
